package week1.day4;

import java.util.Arrays;

/**
 * @Author fengzihao
 * @Date 2024-04-18 19:42
 */
public class MergingTwoArrays {
    public static void main(String[] args) {
        int[] numbers1 = new int[]{1,2,3};
        int[] numbers2 = new int[]{2,2};
        int[] newNumbers = mergingTwoArrays(numbers1,numbers2);
        System.out.println(Arrays.toString(newNumbers));
    }

    private static int[] mergingTwoArrays(int[] numbers1, int[] numbers2) {
        int[] newNumbers = new int[numbers1.length+numbers2.length];
        int i = 0;
        for (; i < numbers1.length; i++) {
            newNumbers[i] = numbers1[i];
        }
        for(;i<numbers1.length+numbers2.length;i++){
            newNumbers[i] = numbers2[i-numbers1.length];
        }
        return newNumbers;
    }
}
